package com.pomelo.base.core.bean;

import java.io.Serializable;

/**
 * 返回结果
 *
 * @author biankudingcha
 * @date: 2021-09-26
 * @since 0.5.0
 */
public class ResultBean implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 成功
     */
    public static final int SUCCESS_CODE = 0;

    /**
     * 失败
     */
    public static final int FAIL_CODE = 1;

    /**
     * 没有权限
     */
    public static final int NO_PERMISSON = 2;

    /**
     * 异常
     */
    public static final int EXCEPTION_CODE = 4;

    /**
     * 业务异常码
     */
    public static final int BIZ_EXCEPTION_CODE = 5;

    private String msg = "";

    private int code = SUCCESS_CODE;

    private boolean success = true;

    private Object data;

    public ResultBean() {
        super();
    }

    public ResultBean(Object data) {
        super();
        this.data = data;
    }

    public ResultBean(Throwable e) {
        super();
        this.msg = e.toString();
        this.code = FAIL_CODE;
    }

    public static ResultBean success() {
        return new ResultBean();
    }

    public static ResultBean success(Object data) {
        return new ResultBean(data);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
